package com.suke.czx.modules.tb.controller;

import java.util.Map;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.web.bind.annotation.*;
import com.suke.czx.modules.tb.entity.TbLikes;
import com.suke.czx.modules.tb.service.TbLikesService;
import com.suke.zhjg.common.autofull.util.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import com.suke.czx.common.annotation.SysLog;
import com.suke.czx.common.base.AbstractController;


/**
 * 点赞表
 *
 * @author developer
 * @email developer@163.com
 * @date 2025-05-17 21:45:12
 */
@RestController
@AllArgsConstructor
@RequestMapping("/tb/likes")
@Api(value = "TbLikesController", tags = "点赞表")
public class TbLikesController extends AbstractController {
    private final TbLikesService tbLikesService;

    /**
     * 列表
     */
    @ApiOperation(value = "点赞表列表")
    @GetMapping("/list")
    public R list(@RequestParam Map<String, Object> params) {
        //查询列表数据
        QueryWrapper<TbLikes> queryWrapper = new QueryWrapper<>();
        final String keyword = mpPageConvert.getKeyword(params);
        if (StrUtil.isNotEmpty(keyword)) {

        }
        IPage<TbLikes> listPage = tbLikesService.page(mpPageConvert.<TbLikes>pageParamConvert(params), queryWrapper);
        return R.ok().setData(listPage);
    }


    /**
     * 新增点赞表
     */
    @ApiOperation(value = "新增点赞表数据")
    @SysLog("新增点赞表数据")
        @PostMapping()
        public R save(@RequestBody TbLikes tbLikes) {
        tbLikesService.save(tbLikes);
        return R.ok();
    }


    /**
     * 修改
     */
    @ApiOperation(value = "修改点赞表数据")
    @SysLog("修改点赞表数据")
        @PutMapping()
        public R update(@RequestBody TbLikes tbLikes) {
        tbLikesService.updateById(tbLikes);
        return R.ok();
    }


    /**
     * 删除
     */
    @ApiOperation(value = "删除点赞表数据")
    @SysLog("删除点赞表数据")
        @DeleteMapping()
        public R delete(@RequestBody TbLikes tbLikes) {
        tbLikesService.removeById(tbLikes.getLikeId());
        return R.ok();
    }

}
